//
//  DCBaseNavController.m
//  Demo
//
//  Created by Kyle on 2022/12/29.
//

#import "DCBaseNavController.h"

@interface DCBaseNavController ()<UINavigationControllerDelegate>

@end

@implementation DCBaseNavController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;

    // Do any additional setup after loading the view.
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
//    if (self.childViewControllers.count >= 1) {
//        viewController.hidesBottomBarWhenPushed = YES;
//    }else{
//        viewController.hidesBottomBarWhenPushed = NO;
//    }
    //iOS 14 bug 修复
    if (self.viewControllers.count > 0) {
        // 当前导航栏, 只有第一个viewController push的时候设置隐藏
        if (self.viewControllers.count >= 1) {
            viewController.hidesBottomBarWhenPushed = YES;
//            [SmartNotificationManager postNotification:@"SmartRootTabBarJumpToSubPage" object:@"hidden"];
        }
    } else {
          viewController.hidesBottomBarWhenPushed = NO;
    }
    
    [super pushViewController:viewController animated:animated];
}

- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
    if (self.viewControllers.count == 2) {
//        [SmartNotificationManager postNotification:@"SmartRootTabBarJumpToSubPage" object:@"show"];
    }
    return [super popViewControllerAnimated:animated];
}

- (NSArray<__kindof UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated
{
    if (self.viewControllers.count > 1) {
        self.topViewController.hidesBottomBarWhenPushed = NO;
    }

    return [super popToRootViewControllerAnimated:animated];
}


-(UIModalPresentationStyle)modalPresentationStyle{
    return UIModalPresentationFullScreen;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
